#include "unity.h"
#include <stdio.h>
#include <stdbool.h>

// 用例的初始化
void setUp(void)
{
}

// 用例的清理
void tearDown(void)
{
}


bool IsTrue(bool in)
{
	return in;
}
 
 
void testBoolPassFunc(void)
{
	TEST_ASSERT_TRUE(IsTrue(true));
}
 
void testBoolFailFunc(void)
{
	TEST_ASSERT_TRUE(IsTrue(false));
}
 
void testIntFunc(void)
{
	TEST_ASSERT_EQUAL_INT(1,1);
	uint8_t v = 10;
	TEST_ASSERT_EQUAL_INT(10, v);
}
 
void testArrayPassFunc(void)
{
	uint8_t a[3] = {1,2,3};
	uint8_t b[3] = {1,2,3};
	TEST_ASSERT_EQUAL_HEX8_ARRAY(a, b, 3);
}
 
void testArrayFailFunc(void)
{
	uint8_t a[3] = {1,2,3};
	uint8_t b[3] = {1,2,4};
	TEST_ASSERT_EQUAL_HEX8_ARRAY(a, b, 3);
}
 
void testBitsFunc(void)
{
	TEST_ASSERT_BITS(0xF0, 0x35, 0x34);
}
 
void testFloatPassFunc(void)
{
	// 这些断言验证actual参数处于expected参数的+/-delta之间。
	TEST_ASSERT_FLOAT_WITHIN(0.4, 1.2, 1.5);
}
 
void testFloatFailFunc(void)
{
	// 这些断言验证actual参数处于expected参数的+/-delta之间。
	TEST_ASSERT_FLOAT_WITHIN(0.2, 1.2, 1.5);
}
 
void testStringFunc(void)
{
	char *s = "hello unity";
	TEST_ASSERT_EQUAL_STRING(s, "hello unity");
}
 
void testStringMessageFunc(void)
{
	char *s = "hello unity";
	TEST_ASSERT_EQUAL_STRING_MESSAGE(s, "hello unity!", "I'm a message!");
}
 
void unit_test(void)
{
	printf("\r\n*****hello unity*******\r\n");
	RUN_TEST(testBoolPassFunc);
	RUN_TEST(testBoolFailFunc);
	RUN_TEST(testIntFunc);
	RUN_TEST(testArrayPassFunc);
	RUN_TEST(testArrayFailFunc);
	RUN_TEST(testBitsFunc);
	RUN_TEST(testFloatPassFunc);
	RUN_TEST(testFloatFailFunc);
	RUN_TEST(testStringFunc);
	RUN_TEST(testStringMessageFunc);
	UNITY_END();
}
